import time
from timeit import timeit

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome(executable_path='Chromedriver.exe')
driver.get("http://121.43.169.97:8848/pageA.html")

# 需求：打cro开注册A.html页面，完成以下操作：
# 1).点击 alert 按钮
# 2).关闭警告框
# 3).输入用户名：admin

# 1).点击 alert 按钮
driver.find_element_by_css_selector("#alerta").click()
time.sleep(2)
# 获取弹出框对象
al = driver.switch_to.alert

# 获取文本信息
print("警告框信息：",al.text)
# 处理对话框
# 1同意
al.accept()


